import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'
/**
 * modules  路由模块
 */
import systemRouter from './modules/system'
import errorRouter from './modules/error'
import truckRouter from './modules/truck'
import dicRouter from './modules/dic'
import userRouter from "./modules/user";


/**
 * @author qun.xu
 * @desc 引入组件模块
 * @date  2018-11-19
 */
// import componentsRouter from './modules/components'
/**
 * @author qun.xu
 * @desc 属性说明如下
 * hidden: true                 如果 hidden 为 true ，不在菜单栏中展示
 * alwaysShow: true   （默认为false,代表子路由只有一个）          如果设置为 true,将一直展示根目录，不管子路由多长，如果没有设置，子路由侠只有一个路由
 * redirect: noredirect         如果设置 redirect: noredirect, 将不在tab面包屑中展示
 * name:'router-name'           设置在 keep-alive 中路由名称
 * meta : {
      roles: ['admin','editor']     控制页面页面显示的角色
      title: 'title'                显示在面包屑中的标题
      icon: 'svg-name'              菜单中的图标
      noCache: true                 设置页面是否缓存，设置为true，将不缓存页面,默认是显示false
    }
  详细文档：https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
*/
/**
 * 全局路由Map
 * @type {*[]}
 */
export const constantRouterMap = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
    name:'Login'
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/authredirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    name: 'Page404',
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    name: 'Page401',
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: 'dashboard', icon: 'dashboard', noCache: true }
      }
    ]
  }
]
export default new Router({
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

/**
 * 动态路由路由Map
 * @type {*[]}
 */
export const asyncRouterMap = [
  // devRouter, //开发路由模块
  errorRouter,
  systemRouter,
  userRouter,
  truckRouter,
  dicRouter,
  { path: '*', redirect: '/404', hidden: true }
]
